package _interview75;

import java.util.Arrays;

/**
 * 2300. 咒语和药水的成功对数
 */
public class No2300 {
    public int[] successfulPairs(int[] spells, int[] potions, long success) {
        Arrays.sort(potions);
        int n = spells.length;
        int m = potions.length;
        int[] ans = new int[n];
        for (int i = 0; i < n; i++) {
            int left = 0, right = m - 1;
            while (left <= right) {
                int mid = left + (right - left >> 1);
                if ((long) potions[mid] * spells[i] < success) left = mid + 1;
                else right = mid - 1;
            }
            ans[i] = m - left;
        }
        return ans;
    }
}
